import json

from pyecharts.charts import Line
from pyecharts.options import TitleOpts, LegendOpts, ToolboxOpts, VisualMapOpts, TooltipOpts, LabelOpts

Japan=open("F:/Python/res/日本.txt", "r", encoding="utf-8")
jp_data=Japan.read()

jp_data=jp_data.replace("jsonp_1629350871167_29498(","")
jp_data=jp_data[:-2]

jp_dict=json.loads(jp_data)

trend_dict=jp_dict["data"][0]["trend"]

x_dict=trend_dict["updateDate"][:314]

y_dict01=trend_dict["list"][0]["data"][:314]
y_dict02=trend_dict["list"][1]["data"][:314]
y_dict03=trend_dict["list"][2]["data"][:314]
y_dict04=trend_dict["list"][3]["data"][:314]

line02=Line()
line02.set_global_opts(
    # 标题名字
    title_opts=TitleOpts(title="2020年日本新型冠状病毒总览图",pos_left="center",pos_bottom="1%"),
    # 图例
    legend_opts=LegendOpts(is_show=True),
    # 工具箱
    toolbox_opts=ToolboxOpts(is_show=True),
    # 视觉映射
    visualmap_opts=VisualMapOpts(is_show=False),

    tooltip_opts=TooltipOpts(is_show=True),
)
line02.add_xaxis(x_dict)
# ,label_opts=LabelOpts(is_show=False)设置数字不显示
line02.add_yaxis("确诊人数",y_dict01,label_opts=LabelOpts(is_show=False),color="red")
line02.add_yaxis("治愈人数",y_dict02,label_opts=LabelOpts(is_show=False),color="blue")
line02.add_yaxis("死亡人数",y_dict03,label_opts=LabelOpts(is_show=False),color="green")
line02.add_yaxis("新增确诊人数",y_dict04,label_opts=LabelOpts(is_show=False),color="yellow")
line02.render("epidemic_Japan.html")